Skip to content

London|May-2025|KhilolaRustamova|Module-Structuring-&-Testing-Data|sprint 3 #636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

HilolaRustam
Copy link

@HilolaRustam HilolaRustam commented Jul 3, 2025

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@HilolaRustam HilolaRustam changed the title London|May-2025|KhilolaRCoursework/sprint 3 London|May-2025|KhilolaRustamova|Module-Structuring-&-Testing-Data|sprint 3 Jul 3, 2025
@HilolaRustam HilolaRustam added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Participant to add when requesting review labels Jul 3, 2025
@illicitonion illicitonion added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Participant to add when requesting review labels Jul 15, 2025
@illicitonion illicitonion changed the base branch from to-be-deleted-coursework/sprint-3 to main July 15, 2025 12:14
Copy link
Member

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is generally looking good, I left a few things for you to think about.

@@ -8,7 +8,16 @@
// write one test at a time, and make it pass, build your solution up methodically
// just make one change at a time -- don't rush -- programmers are deep and careful thinkers
function getCardValue(card) {

const rank = card.slice(0, -1); // remove the suit emoji
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment explains clearly what's going on - nice comment!


if (num >= 2 && num <= 9) return num;

throw new Error("Invalid card rank");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this exception is thrown, it may not be clear to the caller what the invalid rank was - can you think how to make this more clear?

Comment on lines +14 to +16
if (["K", "Q", "J", "10"].includes(rank)) return 10;

const num = parseInt(rank);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but: either of these lines of code could handle the value 10 - why did you decide to handle it in the K/Q/J case rather than the number case?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By grouping "10" with "K", "Q", and "J", you make the intention clear:

"These are all cards that are worth 10 points, no matter what."

It also avoids need of extra range check (num === 10) in the number parsing block, which could make the logic more complex.

@@ -22,3 +22,6 @@ test("should count multiple occurrences of a character", () => {
// And a character char that does not exist within the case-sensitive str,
// When the function is called with these inputs,
// Then it should return 0, indicating that no occurrences of the char were found in the case-sensitive str.

console.log(countChar("hello", "l")); // Should print 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are correct expectations, but they're not tests written in Jest - can you try to write actual tests for these cases?


});
// output
console.log(getOrdinalNumber(1)); // "1st"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, these are fine examples, but they're not jest tests - can you turn them into jest tests?

@@ -13,20 +13,36 @@ test("should repeat the string count times", () => {
const str = "hello";
const count = 3;
const repeatedStr = repeat(str, count);
expect(repeatedStr).toEqual("hellohellohello");
expect(repeat(str, count)).toEqual("hellohellohello");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change this line? What was broken about what it did before?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect(repeat(str, count)).toEqual("hellohellohello");
Calls the repeat() function directly inside the test.
It’s like saying: “Call the function now with str and count, and I expect it to return "hellohellohello".”

before it was saying "I expect the value stored in repeatedStr to equal "hellohellohello"

It might not be broken but i find it unnecessary step

@illicitonion illicitonion added Reviewed Volunteer to add when completing a review and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jul 15, 2025
@HilolaRustam HilolaRustam added Needs Review Participant to add when requesting review and removed Reviewed Volunteer to add when completing a review labels Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review Participant to add when requesting review 📅 Sprint 3 Assigned during Sprint 3 of this module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants